/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 * Origin source from MaNGOS(GPL2).
 * Copyright (C) 2005-2010 MaNGOS <http://getmangos.com/>
 */

#ifndef __PLAYER_H__
#define __PLAYER_H__

#include "Unit.h"

// Player summoning auto-decline time (in secs)
#define MAX_PLAYER_SUMMON_DELAY                   (2*MINUTE)
#define MAX_MONEY_AMOUNT                       (0x7FFFFFFF-1)

namespace PQCore
{
	class Player
		: public Unit
	{
	public:
		static void InitVisibleBits();
		static bool DeleteOldCharacters();
		bool isInWorld();
		void SetCanDelayTeleport(bool set);

		 bool IsHasDelayedTeleport() const
        {
            // we should not execute delayed teleports for now dead players but has been alive at teleport
            // because we don't want player's ghost teleported from graveyard
            return _hasDelayedTeleport && (isAlive() || !_hasBeenAliveAtDelayedTeleport);
        }

		bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options = 0);

        bool TeleportTo(const WorldLocation& loc, uint32 options = 0)
        {
            return TeleportTo(loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation, options);
        }

		 bool Teleport()
        {
			return TeleportTo(_teleportDest,_teleportOptions);
        }

		bool isAlive() const { return (_deathState == ALIVE); };

		void Update(uint32 deltaT);

		float GetPositionX( ) const { return _positionX; }
        float GetPositionY( ) const { return _positionY; }
        float GetPositionZ( ) const { return _positionZ; }

	private:
		bool _canDelayTeleport;
		bool _hasDelayedTeleport;
		bool _hasBeenAliveAtDelayedTeleport;

		float _positionX;
		float _positionY;
		float _positionZ;

		// Current teleport data
        WorldLocation _teleportDest;
        uint32 _teleportOptions;

	};

}
#endif
